﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pattern_Observer
{
    class Subject
    {
        protected IList<Observer> List = new List<Observer>();

        public void Attach(Observer observer)
        {
            List.Add(observer);
        }

        public void Detach(Observer observer)
        {
            List.Remove(observer);
        }

        public void Notify()
        {
            foreach(Observer observer in List)
            {
                observer.Update();
            }
        }


        public string SubjectState
        {
            get;
            set;
        }
    }

    class Subject1 : Subject
    { 
        private string _SubjectState = string.Empty;
        public string SubjectState
        {
            get { return _SubjectState; }
            set { _SubjectState = value; }
        }
    }
}
